package cz.gillan.housecosts.data;


public class Gauge {
	private Long id;
	private GaugeType gaugeType;
	private String name;
	private String serialNumber;
	private Double firstState;
	private Double lastState;
	private String comment;
	private String magnitude;
	
	public Gauge() {
		
	}
	
	public Gauge(Long id) {
		this.id = id;
	}

	public double getConsumption() {
		double value = 0;
		if (lastState != null && firstState != null) {
			value = lastState - firstState;
		}
		return value;
	}
	
//	public double getConsumption(Date from, Date to) {
//		double first = 0;
//		double last = 0;
//		
//		if (states != null && from.before(to)) {
//			for (StateImpl state : states) {
//				if (state.getDate().before(from)) {
//					first = state.getState();
//				}				
//				if (state.getDate().before(to)) {
//					last = state.getState();
//				}
//			}
//		}
//		
//		return last - first;
//	}
	
//	public boolean addState(Date date, Double value, String comment) {
//		StateImpl val = createState(date, value, comment);
//		int position;
//		for (position = states.size() - 1; position >= 0; position++) {
//			State state = states.get(position);
//			if (state.getDate().before(date)) {
//				break;
//			}
//		}
//		states.add(position, val);
//		return true;
//	}
//	
//	public boolean removeState(State state) {
//		states.remove(state);
//		return true;
//	}
	
//	public boolean updateState(State state, Date date, Double value, String comment) {
//		StateImpl val = createState(date, value, comment);
//		int position = states.indexOf(state);
//		if (position != -1) {
//			states.set(position, val);
//		} else {
//			throw new RuntimeException("State object not found"); 
//		}
//		
//		return true;
//	}
	
//	private StateImpl createState(Date date, Double value, String comment) {
//		StateImpl val = new StateImpl(this);
//		val.setDate(date);
//		val.setState(value);
//		val.setComment(comment);
//		return val;
//	}
	
//	public List<State> getStates(Date from, Date to) {
//		List<State> val = new LinkedList<State>();
//		for (StateImpl state : states) {
//			if (state.getDate().after(from) && state.getDate().before(to)) {
//				val.add(state);				
//			}
//		}
//		
//		return val;
//	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the magnitude
	 */
	public String getMagnitude() {
		return magnitude;
	}

	/**
	 * @param magnitude the magnitude to set
	 */
	public void setMagnitude(String magnitude) {
		this.magnitude = magnitude;
	}

	public GaugeType getGaugeType() {
		return gaugeType;
	}
	
	public void setGaugeType(GaugeType gaugeTypeEdit) {
		this.gaugeType = gaugeTypeEdit;
	}
	
	public String getSerialNumber() {
		return serialNumber;
	}
	
	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}
	
	public Double getFirstState() {
		return firstState;
	}
	public void setFirstState(Double firstState) {
		this.firstState = firstState;
	}
	
	public Double getLastState() {
		return lastState;
	}
	
	public void setLastState(Double lastState) {
		this.lastState = lastState;
	}
	
	public String getComment() {
		return comment;
	}
	
	public void setComment(String comment) {
		this.comment = comment;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public Long getId() {
		return id;
	}
}
